package com.czk.netty.netty.tcp.protocaltcp.server;

import com.czk.netty.netty.tcp.protocaltcp.client.MyMessageEncoder;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/1/24 16:04
 */
public class MyServerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        ChannelPipeline pipeline = socketChannel.pipeline();
        // 加入编码器
        pipeline.addLast(new MyMessageEncoder());
        // 加入解码器
        pipeline.addLast(new MyMessageDecoder());
        pipeline.addLast(new MyServerHandler());
    }
}
